mui.init();

var VM = '';

mui.plusReady(function () {
    VM = new Vue({
        el: '#QUEdata',
        data: {
            tiku_list: [],
            loginSta:0,
        },
        mounted: function () {
            this.getTaotiList();
        },
        methods: {
            getTaotiList:function(){
                showWatting();
                var api_host = plus.storage.getItem('HOST_URL');
                mui.ajax({
                    url: api_host + '/api/questionbank/category/newGetGroupCatList',
                    dataType: 'json',
                    headers:{'User-Token':plus.storage.getItem('UserToken')},
                    timeout:3000,
                    data: {
                        'type': 'lists'
                    },
                    type: 'get',
                    success: function (msg) {
                        if (msg.code == 1) {
                            VM.tiku_list = msg.data;
                        } else {
                            mui.toast(msg.msg, {duration: '200',type: 'div'});
                        }
                    },
                    error: function (xhr, type, errorThrown) {
                        mui.toast('加载失败!', {duration: '200',type: 'div'});
                    },
                    complete:function (XMLHttpRequest,status) {
                        plus.nativeUI.closeWaiting();
                    }
                });
            },
            open_tiku_detail: function (dataID) {
                var api_host = plus.storage.getItem('HOST_URL');
                mui.ajax({
                    url: api_host + '/api/questionbank/choice_question/newCheckOnesTestPaperAnalysis',
                    data: {
                        'id': dataID,
                    },
                    headers:{'User-Token':plus.storage.getItem('UserToken')},
                    timeout:3000,
                    dataType: 'json',
                    type: 'get',
                    success: function (msg) {
                        if (msg.code == 1) {
                            mui.openWindow({
                                url: 'oneTestPaper.html',
                                extras: {
                                    'catid': dataID
                                },
                                createNew: false,
                                show: {
                                    autoShow: true,
                                    aniShow: 'pop-in',
                                    duration: 400
                                },
                                waiting: {
                                    autoShow: false,
                                }
                            });
                        } else if (msg.code == 2){
                            mui.openWindow({
                                url: 'oneTestPaperAnalysis.html',
                                extras: {
                                    'catid': dataID
                                },
                                createNew: false,
                                show: {
                                    autoShow: true,
                                    aniShow: 'pop-in',
                                    duration: 400
                                },
                                waiting: {
                                    autoShow: false,
                                }
                            });
                        }else if (msg.code == 3){
                            mui.toast(msg.msg, {duration: '2000',type: 'div'});
                        }else if (msg.code == 4){
                            mui.openWindow({
                                url: 'taotiOrder.html',
                                extras: {
                                    'catid': dataID
                                },
                                createNew: false,
                                show: {
                                    autoShow: true,
                                    aniShow: 'pop-in',
                                    duration: 400
                                },
                                waiting: {
                                    autoShow: false,
                                }
                            });
                        }else{
                            mui.toast(msg.msg, {duration: '2000',type: 'div'});
                        }
                    },
                    error: function (xhr, type, errorThrown) {
                        mui.toast('套题打开失败，请重试', {duration: '1000',type: 'div'});
                    }
                });
            },
        }
    })
})
